<%@ page contentType="text/html; charset=utf-8"%>
<%@ include file="/tags.jsp"%>
<aos:html>
<aos:head title="代理商信息列表">
	<aos:include lib="ext" />
	<aos:base href="console/chargedetail" />
</aos:head>
<aos:body>
</aos:body>
<aos:onready>
	<aos:viewport layout="border">
		<aos:formpanel id="qform" labelWidth="70" region="north"
			header="false" padding="5 0 0 0" border="false">
			<aos:combobox name="agent_id" fieldLabel="代理商名称" labelWidth="100"
				width="400" url="../findAgents" emptyText="－－请选择－－" />
			<aos:button width="80" text="查 询" margin="0 0 0 15px"
				icon="search.png" onclick="query"></aos:button>
			<aos:button width="80" text="重 置" margin="0 0 0 15px"
				icon="refresh1.png" onclick="AOS.reset(qform)"></aos:button>
		</aos:formpanel>
		<aos:gridpanel id="grid" url="list_uncheck" onrender="query"
			onitemdblclick="show_update" region="center">
			<aos:docked>
				<aos:dockeditem onclick="show_update1" text="审核通过" icon="add.png" />
				<aos:dockeditem onclick="show_update" text="审核不通过" icon="edit.png" />
			</aos:docked>
			<aos:selmodel type="checkbox" mode="multi" />
			<aos:column type="rowno" header="序号" width="40" />
			<aos:column header="id" dataIndex="id" width="40" />
			<aos:column header="代理商ID" dataIndex="agent_id" hidden="true" width="60" />
			<aos:column header="代理商名称" dataIndex="agent_name" width="60" />
			<aos:column header="交易金额" dataIndex="charge_money" width="100" />
			<aos:column header="余额" dataIndex="left_money" width="60" />
			<aos:column header="概述" dataIndex="remark" width="130" />
			<aos:column header="操作人 ID" dataIndex="operator_id" width="130" />
			<aos:column header="操作人 " dataIndex="operator_name" width="130" />
			<aos:column header="状态" dataIndex="state" width="60"
				rendererFn="state_ren" />
			<aos:column header="创建时间" dataIndex="create_time" width="130" />
		</aos:gridpanel>


		<aos:window id="update1_w" title="审核通过" maxHeight="-10"
			autoScroll="true">
			<aos:formpanel id="update1_f" width="420" layout="anchor"
				labelWidth="80">
				<aos:textfield name="id" fieldLabel="ID" allowBlank="false"
					readOnly="true" />
				<aos:textfield name="agent_name" fieldLabel="代理商名称"
					allowBlank="false" />

				<aos:textfield name="left_money" fieldLabel="剩余金额"
					allowBlank=" false" />
				<aos:textfield name="charge_money" fieldLabel="交易金额"
					allowBlank="false" />
				<aos:radioboxgroup fieldLabel="审核状态" columns="[150,150]">
					<aos:radiobox name="state" boxLabel="通过" inputValue="2" checked="true" />
					<aos:radiobox name="state" boxLabel="不通过" inputValue="3" />
				</aos:radioboxgroup>
			</aos:formpanel>
			<aos:docked dock="bottom" ui="footer">
				<aos:dockeditem xtype="tbfill" />
				<aos:dockeditem onclick="update1" text="审核通过" icon="ok.png" />
				<aos:dockeditem onclick="#update1_w.hide();" text="关闭"
					icon="close.png" />
			</aos:docked>
		</aos:window>
		<aos:window id="update_w" title="审核不通过" maxHeight="-10"
			autoScroll="true">
			<aos:formpanel id="update_f" width="420" layout="anchor"
				labelWidth="80">
				<aos:textfield name="id" fieldLabel="ID" allowBlank="false"
					readOnly="true" />
				<aos:textfield name="agent_name" fieldLabel="代理商名称"
					allowBlank="false" />

				<aos:textfield name="left_money" fieldLabel="剩余金额"
					allowBlank=" false" />
				<aos:textfield name="charge_money" fieldLabel="交易金额"
					allowBlank="false" />
				<aos:radioboxgroup fieldLabel="审核状态" columns="[150,150]">
					<aos:radiobox name="state" boxLabel="通过" inputValue="2" />
					<aos:radiobox name="state" boxLabel="不通过" inputValue="3"
						checked="true" />
				</aos:radioboxgroup>
			</aos:formpanel>
			<aos:docked dock="bottom" ui="footer">
				<aos:dockeditem xtype="tbfill" />
				<aos:dockeditem onclick="update" text="审核不通过" icon="ok.png" />
				<aos:dockeditem onclick="#update_w.hide();" text="关闭"
					icon="close.png" />
			</aos:docked>
		</aos:window>
	</aos:viewport>

	<script type="text/javascript">
    
    function state_ren(v){
		if(v == 1){
			return '待审核'
		}else if(v == 2){
			return '审核通过'
		}else if(v == 3){
			return '审核不通过'
		}else{
			return v
		}
	}
    
   	 
    function query(){
        grid_store.getProxy().extraParams = qform.getValues();
        grid_store.getProxy().getMethod = function(){ return 'POST'; }
        grid_store.load();
     }

	function show_add(){
		AOS.reset(add_f);
        add_w.show();
	}
	
	function add(){
		AOS.ajax({
            forms : add_f,
            url : 'add',
            ok : function(data) {
                	if(data.success){
                		 add_w.hide();
                     grid_store.reload();
                	}
                AOS.tip(data.appmsg);
            }
        }); 
	}
	
    function show_update(){
        AOS.reset(update_f);
        grid_store.reload();           
        var record = AOS.selectone(grid);
        grid.getSelectionModel().clearSelections();
        if(record){
            update_w.show();
            update_f.loadRecord(record);
        }
    }   
    
    function show_update1(){
        AOS.reset(update1_f);
        grid_store.reload();           
        var record = AOS.selectone(grid);
        grid.getSelectionModel().clearSelections();
        if(record){
            update1_w.show();
            update1_f.loadRecord(record);
        }
    }  
    
    function update(){
           AOS.ajax({
            forms : update_f,
            url : 'update',
            ok : function(data) {
                	if(data.success){
                		update_w.hide();
                    grid_store.reload();
                    grid.getSelectionModel().clearSelections()
                	}
                	AOS.tip(data.appmsg);
            }
        }); 
    }
    
    function update1(){
        AOS.ajax({
         forms : update1_f,
         url : 'update',
         ok : function(data) {
             	if(data.success){
             		update1_w.hide();
                 grid_store.reload();
                 grid.getSelectionModel().clearSelections()
             	}
             	AOS.tip(data.appmsg);
         }
     }); 
 }
    </script>
</aos:onready>
</aos:html>